#include <stdio.h>
#include <math.h>
int main()
{
    int s, v,  time, h, min;
    double t;

    scanf("%d %d", &s, &v);
    t = ceil(s *1.0/ v)+10;
    if (t <= 8)
    {
        time = 8 * 60 - t;
        h = time / 60;
        min = time % 60;
    }
    else
    {
        time = 24 * 60 - t;
        h = time / 60;
        min = time % 60;
        if (h >= 16)
        {
            h = h - 16;
        }
    }
    if (h < 10)
    {
        printf("%02d:%d\n", h, min);
    }
    else
        printf("%d %d\n", h, min);

    return 0;
}